from __future__ import annotations

from datetime import date
from typing import Optional

from app.schemas.common import APIModel, Timestamped


class AnniversaryBase(APIModel):
  name: str
  date: date
  recurrence: str = "yearly"
  reminder_offset_days: int = 7
  is_lunar: bool = False
  lunar_date_str: Optional[str] = None
  countdown_mode: str = "down"


class AnniversaryCreate(AnniversaryBase):
  # 允许仅提供农历信息创建，此时 date 可缺省
  date: Optional[date] = None


class AnniversaryUpdate(APIModel):
  name: Optional[str] = None
  date: Optional[date] = None
  recurrence: Optional[str] = None
  reminder_offset_days: Optional[int] = None
  is_lunar: Optional[bool] = None
  lunar_date_str: Optional[str] = None
  countdown_mode: Optional[str] = None


class AnniversaryResponse(AnniversaryBase, Timestamped):
  id: int
  relationship_id: Optional[int] = None
